package filmring

import grails.test.*

class SearchServiceTests extends GroovyTestCase {

    def searchService

    protected void setUp() {
        super.setUp()
    }

    protected void tearDown() {
        super.tearDown()
    }

    void testSearchMovies() {
        Movie m = Movie.findByTitle("The Social Network")
        List<Movie> movies = searchService.searchMovies("SOCIAL")
        assert(movies.indexOf(m) > -1)      //Checks if Movie m is in search results
    }

    void testSearchActors() {
        Actor a = Actor.findByName("Liam Neeson")
        List<Actor> actors = searchService.searchActors("Liam")
        assert(actors.indexOf(a) > -1)      //Checks if Actor a is in search results

        List<Actor> noActors = searchService.searchActors("qqewlyveblibfsmdcskbkbckwbrcruebcrukebcuerskm")
        assert(noActors.size() == 0)
        assertNotNull(noActors)
    }

    void testSearchDirectors() {
        Director d = Director.findByName("Martin Scorsese")
        List<Director> directors = searchService.searchDirectors("MART")
        assert(directors.indexOf(d) > -1)   //Checks if Director d is in search results
    }
}
